assert(PandaDKPMaster, "PandaDKPMaster not found!")

------------------------------
--      Are you local?      --
------------------------------
local PandaDKPMaster = PandaDKPMaster
local Comm =
{
}
PandaDKPMaster.Comm = Comm


function Comm:Enable()
   PandaDKPMaster:RegisterComm("PDKPM", function(a,b,c,d) Comm:MessageReceived(a,b,c,d) end)
   PandaDKPMaster:RegisterComm("PDKP", function(a,b,c,d) Comm:MessageReceived(a,b,c,d) end)
end



function Comm:MessageReceived(prefix, message, distribution, sender)
   --PandaDKPMaster:Print(string.format("Received from %s '%s' on %s", sender, message, distribution))
   --tinsert(PandaDKPMaster.db.realm.DKP.Logging, string.format("Received from %s '%s' on %s", sender, message, distribution))
   PandaDKPMaster.Messages:QueueMessage(sender, prefix, message)
end


function Comm:Send(channel, message, target)
   if (nil ~= target) then
      --PandaDKPMaster:Print(string.format("Sending %s to %s", message, target))
      --tinsert(PandaDKPMaster.db.realm.DKP.Logging, string.format("Sending %s to %s", message, target))
   else
      --PandaDKPMaster:Print(string.format("Sending %s on %s", message, channel))
      --tinsert(PandaDKPMaster.db.realm.DKP.Logging, string.format("Sending %s on %s", message, channel))
   end
   PandaDKPMaster:SendCommMessage("PDKPM", message, channel, target)
end

function Comm:SendBulk(channel, message, target)
   --PandaDKPMaster:Print(string.format("Sending %s on %s", message, channel))
   PandaDKPMaster:SendCommMessage("PDKPM", message, channel, target, "BULK")
end

function Comm:SendClient(channel, message, target)
   --PandaDKPMaster:Print(string.format("Sending %s on %s", message, channel))
   PandaDKPMaster:SendCommMessage("PDKP", message, channel, target)
end

function Comm:SendClientBulk(channel, message, target)
   --PandaDKPMaster:Print(string.format("Sending %s on %s", message, channel))
   PandaDKPMaster:SendCommMessage("PDKP", message, channel, target, "BULK")
end